package com.example.flowermall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.flowermall.entity.InvitationOrder;
import com.example.flowermall.mapper.InvitationOrderMapper;
import com.example.flowermall.service.InvitationOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (InvitationOrder)表服务实现类
 *
 * @author mq
 * @since 2025-03-17 15:49:54
 */
@Service("invitationOrderService")
public class InvitationOrderServiceImpl extends ServiceImpl<InvitationOrderMapper, InvitationOrder> implements InvitationOrderService {
    @Resource
    private InvitationOrderMapper invitationOrderMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public InvitationOrder queryById(Integer id) {
        return this.invitationOrderMapper.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param invitationOrder 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(InvitationOrder invitationOrder) {
        invitationOrder.setStatus("0");
        return invitationOrderMapper.insert(invitationOrder);
    }

    /**
     * 修改数据
     *
     * @param invitationOrder 实例对象
     * @return 实例对象
     */
    @Override
    public InvitationOrder update(InvitationOrder invitationOrder) {
        this.invitationOrderMapper.update(invitationOrder);
        return this.queryById(invitationOrder.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.invitationOrderMapper.deleteById(id) > 0;
    }
}
